package com.qny.ai.controller;

import com.qny.ai.service.impl.QiniuVoiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/test")
public class TestController {
    
    @Autowired
    private QiniuVoiceService qiniuVoiceService;
    
    @GetMapping("/asr")
    public String testASR() {
        try {
            // 使用七牛云官方示例音频进行测试
//            String testUrl = "https://static.qiniu.com/ai-inference/example-resources/example.mp3";
            String testUrl = " http://t3320eebr.hd-bkt.clouddn.com/audio/2025-09-27/1ef69350-342d-4f0f-b21b-d11b3b35024e.dat";
//            String result = qiniuVoiceService.asrByUrl(testUrl, "mp3");
            String result = qiniuVoiceService.asrByUrl(testUrl, "raw");
            return "ASR Test Result: " + result;
        } catch (Exception e) {
            return "ASR Test Error: " + e.getMessage();
        }
    }
}
